package com.mk.cloud.pt.controller.platform;

import act.apidoc.Description;
import act.controller.Controller;
import act.inject.DefaultValue;
import com.mk.cloud.common.domain.PReward;
import com.mk.cloud.common.domain.PWalletFlow;
import com.mk.cloud.common.interceptor.cookie.CookieService;
import com.mk.cloud.common.interceptor.cookie.ICLogin;
import org.beetl.sql.core.engine.PageQuery;
import org.osgl.mvc.annotation.GetAction;
import org.osgl.mvc.annotation.With;

import javax.inject.Inject;
import java.util.HashMap;
import java.util.Map;

@Controller("/reward")
public class PRewardController  extends CookieService {

    @Inject
    private PReward.Mapper pRewardMapper;

    @Description("实物奖励列表")
    @GetAction("rewardList.json")
    @With(ICLogin.class)
    public PageQuery<PReward> pRewardList(
            String fuserid,
            @Description("当前第几页") @DefaultValue("1") Integer page,
            @Description("每页多少条") @DefaultValue("15") Integer size

    ) {
        PageQuery<PReward> query = new PageQuery<>();
        query.setPageSize(size);
        query.setPageNumber(page);
        Map<String, Object> map = new HashMap<>();
        map.put("coid", me.getCoid());
        map.put("fuserid", fuserid);
        query.setParas(map);
        pRewardMapper.getSQLManager().pageQuery("pReward.select_reward_page_list", PReward.class, query);
        return query;
    }

    @Description("现金奖励列表")
    @GetAction("cashList.json")
    @With(ICLogin.class)
    public PageQuery<PWalletFlow> cashList(
            String fuserid,
            @Description("当前第几页") @DefaultValue("1") Integer page,
            @Description("每页多少条") @DefaultValue("15") Integer size
    ) {
        PageQuery<PWalletFlow> query = new PageQuery<>();
        query.setPageSize(size);
        query.setPageNumber(page);
        Map<String, Object> map = new HashMap<>();
        map.put("coid", me.getCoid());
        map.put("fuserid", fuserid);
        query.setParas(map);
        pRewardMapper.getSQLManager().pageQuery("pReward.select_cash_page_list", PWalletFlow.class, query);
        return query;
    }
}
